﻿using System;
using System.Windows.Data;

namespace TheVerge.Phone.Converters
{
    public class CasingConverter : IValueConverter
    {
        public Casing DesiredCasing { get; set; }
        
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (null != value)
            {
                var str = value.ToString();

                switch (DesiredCasing)
                {
                    case Casing.AllUpper:
                        return str.ToUpper();
                    case Casing.AllLower:
                        return str.ToLower();
                    default:
                        return str;
                }
            }

            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public enum Casing
    {
        AllUpper,
        AllLower
    }
}
